import request from "@/utils/request";
// 分类：获取文章分类
export const artGetChannelsService = () => request.get("/cate/list");
// 分类：添加文章分类
export const artAddChannelService = (data) => request.post("/cate/add", data);
// 分类：编辑文章分类
export const artEditChannelService = (data) => request.put("/cate/info", data);
// 分类：删除文章分类
export const artDelChannelService = (id) =>
  request.delete("/cate/del", {
    params: { id },
  });

export const updateFile = (formData) =>
  request.post("/common/update", formData, {
    headers: {
      "Content-Type": "multipart/form-data",
    },
  });

// 文章：获取文章列表
export const artGetListService = (params) =>
  request.get("/article/list", {
    params,
  });

// 文章：添加文章
// 注意：data需要是一个formData格式的对象
export const artPublishService = ({
  title,
  cate_id,
  cover_img,
  content,
  state,
}) =>
  request.post("/article/add", { title, cate_id, cover_img, content, state });

// 文章：获取文章详情
export const artGetDetailService = (id) =>
  request.get("/article/info", {
    params: { id },
  });

// 文章：编辑文章接口
export const artEditService = ({
  id,
  title,
  cate_id,
  cover_img,
  content,
  state,
}) =>
  request.put("/article/info", {
    id,
    title,
    cate_id,
    cover_img,
    content,
    state,
  });

// 文章：删除文章接口
export const artDelService = (id) =>
  request.delete("/article/info", { params: { id } });
